<?php
/**
 * Description of txtlocal
 *
 * @author Teis Lindemark
 */
class txtlocal {
    private $username = null;
    private $password = null;
    private $info = null;
    private $test = null;
    private $from = null;
    private $selectednums = null;
    private $message = null;
    
    function __construct($info, $test, $from) {
        $this->username = 'teis.lindemark@iaeste.no';
        $this->password = 'oipt737oi!';
        $this->info = $info;
        $this->test = $test;
        $this->from = $from;
    }
    
    function sendSMS($number, $message) {
        $this->selectednums = $number;
        $this->message = urlencode($message);
        
        //Prepare data for POST request
        $data = "uname=" . $this->username . "&pword=" . $this->password . "&message=" . $this->message;
        $data .= "&from=".$this->from."&selectednums=".$this->selectednums."&info=".$this->info."&test=".$this->test;
        
        //Send POST request with cURL
        $curl = curl_init('http://www.txtlocal.com/sendsmspost.php');
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($curl); //This is the result from Txtlocal
        curl_close($curl);
        
        return $result;
    }
}

?>
